package com.sundi.ecsystem.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.sundi.ecsystem.entity.EcRoleMenu;
import com.sundi.ecsystem.mapper.EcRoleMenuMapper;
import com.sundi.ecsystem.service.IEcRoleMenuService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mht
 * @since 2020-02-25
 */
@Service
public class EcRoleMenuServiceImpl extends ServiceImpl<EcRoleMenuMapper, EcRoleMenu> implements IEcRoleMenuService {

    @Override
    @Transactional
    public void save(List<EcRoleMenu> menuRoleList) {
        Wrapper<EcRoleMenu> wrapper = new EntityWrapper<EcRoleMenu>();
        wrapper.eq("role_id",menuRoleList.get(0).getRoleId());
        this.delete(wrapper);
        this.insertBatch(menuRoleList);
    }
}
